/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jate.core;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 *
 * @author milan
 */
public class YateMessage {
    public String type;
    public String name;
    public String retVal;
    public String id;
    public boolean handled;
    public long origin;
    public Map<String, String> params;

    public YateMessage(String name, String retVal, String id) {
        this.type = "outgoing";
        this.name = name;
        this.retVal = retVal;
        this.id = id;
        this.handled = false;
        this.origin = (int)(new Date().getTime() / 1000);
        this.params = new HashMap<String, String>();
    }

    public YateMessage(String name, String retVal) {
        this(name, retVal, UUID.randomUUID().toString());
    }

    public YateMessage(String name) {
        this(name, "");
    }

  @Override public String toString() {
    StringBuilder result = new StringBuilder();
    String NEW_LINE = System.getProperty("line.separator");

    result.append(NEW_LINE + this.type + "." + this.name + " YateMessage {" + NEW_LINE);
    result.append("  retVal: " + this.retVal + NEW_LINE);
    result.append("  handled: " + this.handled + NEW_LINE);
    result.append("  params: " + this.params + NEW_LINE);
    result.append("}" + NEW_LINE);

    return result.toString();
  }

}
